<template>
  <default-layout>
    <header-back text="党员缴费" slot="header"></header-back>
    <loading-text v-if="loading" slot="main"></loading-text>
    <div class="form-list" slot="main" v-if="!loading && detail.content">
      <div class="form-list-item">
        <span class="label">姓名：</span>
        <span class="content">{{detail.personName}}</span>
      </div>
      <div class="form-list-item">
        <span class="label">档案号：</span>
        <span class="content">{{userInfo.archiveCode}}</span>
      </div>
      <div class="form-list-item">
        <span class="label">党员编号（身份证号）：</span>
        <span class="content">{{detail.personCard}}</span>
      </div>
      <div class="form-list-item">
        <span class="label">缴费年度：</span>
        <span class="content">{{detail.content.month}}</span>
      </div>
    </div>
    <div class="next" slot="footer">
      <mt-button size="large" type="primary" @click="getOrder">确定</mt-button>
    </div>
  </default-layout>
</template>
<script>
  import HeaderBack from '../../../components/header-back/header-back.vue'
  import DefaultLayout from '../../../layouts/default-layout/default-layout'
  import {mapGetters, mapMutations} from 'vuex'
  import {delNull} from '../../../common/js/util'
  import LoadingText from '../../../components/loading-text/loading-text'

  export default {
    components: {LoadingText, DefaultLayout, HeaderBack},
    data() {
      return {
        detail: {},
        loading: true
      }
    },
    computed: {
      ...mapGetters([
        'userInfo'
      ])
    },
    methods: {
      ...mapMutations({
        setOrder: 'SET_ORDER'
      }),
      getMonth() {
        // 获取缴费月份
        this.$post('/admin/person/sapi/party/pay/get/month', {}, loading => {
          this.loading = loading
        }).then(res => {
          /*
          * result
          * 10001 用户还未进行授权
          * 10002 用户授权认证失败
          * 10003 用户还没有档案信息
          * 10004 用户还没有党员信息
          * 10005 用户还没有录入继续教育
          * 10006 党员缴费还有未交费订单
          * 10007 用户的党员组织关系信息已存在
          * 10008 用户的档案信息已存在
          * */
          if (res.result === 1) {
            delNull(res.data.content)
            this.detail = res.data
          } else {
            this.$message.alert(res.message).then(() => {
              this.$router.back()
            })
          }
        })
      },
      getOrder() {
        this.$post('/admin/person/sapi/party/pay/get/amount', {}, loading => { this.$message.loading(loading) }).then(res => {
          if (res.result === 1) {
            const detail = res.data.content
            this.setOrder(detail)
            this.$router.replace({
              name: 'payWay',
              query: {
                type: 'party'
              }
            })
          } else {
            this.$message.alert(res.message).then(() => {
              this.$router.back()
            })
          }
        })
      }
    },
    created() {
      this.getMonth()
    }
  }
</script>
<style scoped lang="scss">
  @import "../../../common/style/variable";
</style>
